<?php

class CountComponent extends Core {	
	public function accounts() {
		$rs = $this->Database->query('SELECT COUNT(1) AS total FROM MEMB_INFO')->fetch();
		return $rs['total'];
	}
	
	public function characters() {
		$rs = $this->Database->query('SELECT COUNT(1) AS total FROM Character')->fetch();
		return $rs['total'];
	}
	
	public function guilds() {
		$rs = $this->Database->query('SELECT COUNT(1) AS total FROM Guild')->fetch();
		return $rs['total'];
	}
	
	public function characters_by_class($class) {
		$rs = $this->Database->query('SELECT COUNT(1) AS total FROM Character WHERE Class = %s', $class)->fetch();
		return $rs['total'];
	}
	
	public function banned_accounts() {
		$rs = $this->Database->query('SELECT COUNT(1) AS total FROM MEMB_INFO WHERE bloc_code = 1')->fetch();
		return $rs['total'];		
	}
	
	public function banned_characters() {
		$rs = $this->Database->query('SELECT COUNT(1) AS total FROM Character WHERE CtlCode = 1')->fetch();
		return $rs['total'];		
	}
	
	public function onlines() {
		$rs = $this->Database->query('SELECT COUNT(1) AS total FROM MEMB_STAT WHERE ConnectStat > 0')->fetch();
		return $rs['total'];		
	}
	
	public function onlines_by_server($server = null) {
		$rs = $this->Database->query('SELECT COUNT(1) AS total FROM MEMB_STAT WHERE ConnectStat > 0 AND ServerName = %s', $server)->fetch();
		return $rs['total'];		
	}
}

?>